home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / INPUT / RAW_FOCU.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  3.0 KB  |  93 lines

  1.  
  2. package sub_arctic.input;
  3.  
  4. import sub_arctic.lib.interactor;
  5.  
  6. /** 
  7.  * This class implements the raw focus agent.  This agent is focus based and
  8.  * delivers raw events to requesting objects.  This can be used as a hook for
  9.  * extensions.  This agent handles the raw_input_acceptor input protocol.
  10.  *
  11.  * @see sub_arctic.input.raw_input_acceptor
  12.  * @author Scott Hudson
  13.  */
  14. public class raw_focus_agent extends focus_dispatch_agent {
  15.  
  16.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  17.  
  18.   /** Simple constructor. */
  19.   public raw_focus_agent()
  20.     {
  21.     }
  22.  
  23.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  24.  
  25.   /** Allow objects in this focus set only if they implement the 
  26.    *  raw_input_acceptor interface. 
  27.    *
  28.    * @param focusable candidate_obj the object we are testing for suitability.
  29.    * @return boolean indicating if the object is suitable to go in the focus set
  30.    */
  31.   public boolean allowable_focus(focusable candidate_obj)
  32.     {
  33.       return candidate_obj instanceof raw_input_acceptor;
  34.     }
  35.  
  36.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  37.  
  38.   /** 
  39.    * Attempt to dispatch an event under this agent.  
  40.    *
  41.    * @param event      evt       the event to try to dispatch.
  42.    * @param Object     user_info ignored (since this is a focus agent).
  43.    * @param interactor to_obj    ignored (since this is a focus agent).
  44.    * @param int        seq_num   ignored (since this is a focus agent).
  45.    * @return boolean indicating whether the event was consumed.
  46.    */
  47.   public boolean dispatch_event(
  48.     event      evt,
  49.     Object     user_info,
  50.     interactor to_obj,
  51.     int        seq_num)
  52.     {
  53.       int i;
  54.       raw_input_acceptor dispatch_to_obj;
  55.       boolean result = false;
  56.       event   evt_copy;
  57.  
  58.       /* copy event */
  59.       evt_copy = new event(evt);
  60.  
  61.       /* do a dispatch of raw event to each element of the focus set */
  62.       for (i = 0; i < focus_set_size(); i++)
  63.     {
  64.       /* extract the object and dispatch to it */
  65.       dispatch_to_obj = (raw_input_acceptor)focus_item(i);
  66.       if (dispatch_to_obj instanceof interactor)
  67.         evt_copy.global_to_local((interactor)dispatch_to_obj);
  68.       else
  69.         evt_copy.reset_to_global();
  70.       result |= dispatch_to_obj.handle_raw_input(evt_copy,user_info);
  71.     }
  72.       return result;
  73.     }
  74.  
  75.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  76. }
  77. /*=========================== COPYRIGHT NOTICE ===========================
  78.  
  79. This file is part of the subArctic user interface toolkit.
  80.  
  81. Copyright (c) 1996 Scott Hudson and Ian Smith
  82. All rights reserved.
  83.  
  84. The subArctic system is freely available for most uses under the terms
  85. and conditions described in 
  86.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  87. and appearing in full in the lib/interactor.java source file.
  88.  
  89. The current release and additional information about this software can be 
  90. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  91.  
  92. ========================================================================*/
  93.